<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .minyuan_red{padding: 4px;background-color: red;border-radius: 50%;font-size: 0!important;margin-right: 6px;position: relative;top: -4px;}
    .minyuan_lv{padding: 4px;background-color: #19BE6B;border-radius: 50%;font-size: 0!important;margin-right: 6px;position: relative;top: -4px;}
    xm-select{min-height: 30px!important;line-height: 30px!important;}
    xm-select > .xm-label .xm-label-block{margin: 0!important;}
    xm-select > .xm-label .scroll .label-content{padding: 1px 10px!important;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">人员姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">员工编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">身份证号</label>
                        <div class="layui-input-block">
                            <input type="text" name="idcard" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-block">
                            <select name="sex" lay-filter="sex" >
                                <option value="">请选择</option>
                                <option value="男">男</option>
                                <option value="女">女</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">出生日期：</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="birdt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">民族</label>
                        <div class="layui-input-block">
                            <input type="text" name="nation" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">籍贯</label>
                        <div class="layui-input-block">
                            <input type="text" name="jiguan" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">政治面貌</label>
                        <div class="layui-input-block">
                            <input type="text" name="mian" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="tel" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">学历：</label>
                        <div class="layui-input-block">
                            <div id="xueli" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">人员性质</label>
                        <div class="layui-input-block">
                            <div id="nature" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">入职日期：</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="intodt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">岗位</label>
                        <div class="layui-input-block">
                            <div id="gangid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <input type="hidden" name="deptid" id="deptid">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md2" id="navselect">
                <div class="navselect_bac">
                    <div class="navselect_div">
                        <div class="navselect_title">单位/部门</div>
                        <div class="navselect_nav">
                            <a id="tree_pand" title="收起/展开">收起</i></a>&nbsp;
                            <a id="tree_search" title="刷新"><i class="layui-icon layui-icon-refresh-1"></i></a>
                        </div>
                    </div>
                    <div>
                        <button type="button" class="layui-btn layui-btn-sm typeall">
                        <i class="layui-icon layui-icon-home"></i>&nbsp;&nbsp;&nbsp;全部
                        </button>
                    </div>
                    <div id="tree_content"></div>
                </div>
            </div>

            <div class="layui-col-md10" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var currButAuth, currTabData, treeObj, deptTreeData=[], deptTreeStatus=1;
    layui.use(["tree", "laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var tree = layui.tree,laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        getDeptData();
        $("#tree_search").click(function () {
            $("#deptid").val(0)
            searchTableFunc(form, table);
            getDeptData();
        });
        $('#tree_pand').click(function () {
            if(deptTreeStatus == 1){
                treeObj.reload({id: 'tree_content',data: opt_tree(deptTreeData, false)});
                deptTreeStatus = 2;
                $("#tree_pand").html('展开');
            }else{
                treeObj.reload({id: 'tree_content',data: opt_tree(deptTreeData, true)});
                deptTreeStatus = 1;
                $("#tree_pand").html('收起');
            }
        });
        function getDeptData() {
            facade.ajax({url: ask_user_dept_list}).done(function(res){
                if (res.code === 2000) {
                    deptTreeData = res.data;
                    deptTreeStatus = 1;
                    $("#tree_pand").html('收起');
                    treeObj = tree.render({
                        elem: '#tree_content'
                        ,id: 'tree_content'
                        ,data: deptTreeData
                        ,onlyIconControl: true
                        ,click: function(obj){
                            $("#deptid").val(obj.data.id)
                            searchTableFunc(form, table);

                            $('.layui-tree-entry').each(function () {
                                $(this).find('.layui-tree-txt').removeClass('layui-tree-other');
                            });
                            $(obj.elem).find('.layui-tree-entry').eq(0).find('.layui-tree-txt').addClass('layui-tree-other');
                        }
                    });
                    var height = $('.laytp-container').height() - 220 + 'px';
                    $('#tree_content').css('cssText','max-height:'+height);
                }
            });
        }

        $('.typeall').click(function () {
            $('.layui-tree-entry').each(function () {
                $(this).find('.layui-tree-txt').removeClass('layui-tree-other');
            });
            $("#deptid").val(0)
            searchTableFunc(form, table);
        });


        setSouTableExport('入职审批');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cert_perru_list),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response
            ,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                xmselect_dan('nature', res.data.nature, res.data.is_nature, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xmselect_dan('xueli', res.data.xueli, res.data.is_xueli, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                });
                xmselect_dan('gangid', res.data.gangArr, res.data.is_gangid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                });


                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{type:'numbers',title:'序号',fixed:'left'}
                ,list_bill_cols_str
                ,{field: 'name', title: '人员姓名'}
                ,{field: 'number', title: '员工编号'}
                ,{field: 'idcard', title: '身份证号'}
                ,{field: 'sex', title: '性别'}
                ,{field: 'birdt', title: '出生日期'}
                ,{field: 'nation', title: '民族'}
                ,{field: 'jiguan', title: '籍贯'}
                ,{field: 'mian', title: '政治面貌'}
                ,{field: 'addr', title: '家庭住址'}
                ,{field: 'tel', title: '联系电话'}
                ,{field: 'jiner', title: '紧急联系人'}
                ,{field: 'jintel', title: '紧急联系人电话'}
                ,{field: 'school', title: '毕业学校'}
                ,{field: 'xueli', title: '学历'}
                ,{field: 'major', title: '专业'}
                ,{field: 'schooldt', title: '毕业日期'}
                ,{field: 'zhilevel', title: '职称职级'}
                ,{field: 'nature', title: '人员性质'}
                ,{field: 'intodt', title: '入职日期'}
                ,{field: 'deptid_name', title: '部门'}
                ,{field: 'gangid_name', title: '岗位'}
                ,{field: 'shenum', title: '社保卡号'}
                ,{field: 'gongnum', title: '公积金号'}
                ,{field: 'bankname', title: '银行账户'}
                ,{field: 'banknum', title: '银行账号'}
                ,{field: 'bankkai', title: '开户行'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });

        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('show.php?id='+trData.id);
    }
    function auth_but_func_add_flow(){
        openPageEdit('flow_add.php?close=1');
    }
    function auth_but_func_delete(buttitle, index){
        var trData = currTabData[index];
        data_delete(ask_cert_perru_del, {id:trData.id});
    }






    function opt_tree(data, status) {
        for (var i=0;i<data.length;i++){
            data[i]['spread'] = status;
            if(data[i].children != undefined){
                opt_tree(data[i].children, status);
            }
        }
        return data;
    }

</script>
</body>
</html>
